package com.dexgdx.game.structure.base;

import com.badlogic.gdx.math.Rectangle;
import com.dexgdx.game.Game;

public class BaseRegion extends Rectangle {
	
	private static final long serialVersionUID = -3649759885863145011L;
	protected boolean solidObject;
	
	public BaseRegion(float x, float y, float height, float width) {
		super(x, y, width, height);
	}
	
	public void setFromRegion(BaseRegion fromRegion){
		x = fromRegion.x;
		y = fromRegion.y;
		height = fromRegion.height;
		width = fromRegion.width;
	}
	
	public void setToRegion(BaseRegion toRegion){
		toRegion.x = x;
		toRegion.y = y;
		toRegion.height = height;
		toRegion.width = width;
	}
	
	public static BaseRegion fromCursorToMiddlePosition(float x, float y, BaseRegion region){
		BaseRegion newRegion = new BaseRegion(x, y, region.getHeight(), region.getWidth());
		newRegion.x = x - newRegion.width/2;
		newRegion.y = y - newRegion.height/2;
		return newRegion;
	}
	
	public BaseRegion cloneRegion(){
		return new BaseRegion(x, y, height, width);
	}
	
	public boolean isCollidingWith(BaseRegion baseRegion) {
		return this.overlaps(baseRegion);
	}

	public boolean isOneStepAwayFrom(BaseRegion baseRegion, float stepSize){
		return Math.abs(x - baseRegion.x) < stepSize && Math.abs(y - baseRegion.y) < stepSize;
	}
	
	public boolean isSamePositionAs(BaseRegion region){
		return (x == region.x && y == region.y);
	}

	public boolean isSolidObject() {
		return solidObject;
	}
}
